{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# To capture the NNP library stdout output we have two possible options:\n",
    "#\n",
    "# 1.) Install \"wurlitzer\" available via pip or github.com/minrk/wurlitzer\n",
    "#     > pip install wurlitzer\n",
    "#     and load as extension\n",
    "#     > %load_ext wurlitzer\n",
    "#\n",
    "# 2.) Silence the library output (which will otherwise go to Jupyter server shell)\n",
    "#     > nnp = pynnp.Mode()\n",
    "#     > nnp.log.writeToStdout = False\n",
    "#     > ... do initialization ...\n",
    "#     and recall the log later:\n",
    "#     > for line in nnp.log.getLog():\n",
    "#     >     sys.stdout.write(line)\n",
    "#\n",
    "# Option 1.) is obviously more comfortable and will also capture output to stderr.\n",
    "%load_ext wurlitzer\n",
    "import pynnp\n",
    "from sys import stdout as so"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create instance of NNP setup.                               \n",
    "nnp = pynnp.Mode()\n",
    "\n",
    "# Turn off output to stdout (for Option 2.) described above).\n",
    "#nnp.log.writeToStdout = False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "*******************************************************************************\n",
      "\n",
      "   NNP LIBRARY v2.0.0\n",
      "   ------------------\n",
      "\n",
      "Git branch  : master\n",
      "Git revision: e7a2975 (e7a29759d35de1e94b09bf88b270a76e20f41323)\n",
      "\n",
      "*******************************************************************************\n",
      "\n",
      "*** SETUP: SETTINGS FILE ******************************************************\n",
      "\n",
      "Settings file name: input.nn\n",
      "Read 175 lines.\n",
      "Found 102 lines with keywords.\n",
      "*******************************************************************************\n",
      "\n",
      "*** SETUP: ELEMENT MAP ********************************************************\n",
      "\n",
      "Number of element strings found: 2\n",
      "Element  0:  H (  1)\n",
      "Element  1:  O (  8)\n",
      "*******************************************************************************\n",
      "\n",
      "*** SETUP: ELEMENTS ***********************************************************\n",
      "\n",
      "Number of elements is consistent: 2\n",
      "Atomic energy offsets per element:\n",
      "Element  0:   0.00000000E+00\n",
      "Element  1:   0.00000000E+00\n",
      "Energy offsets are automatically subtracted from reference energies.\n",
      "*******************************************************************************\n",
      "\n",
      "*** SETUP: CUTOFF FUNCTIONS ***************************************************\n",
      "\n",
      "Parameter alpha for inner cutoff: 0.000000\n",
      "Inner cutoff = Symmetry function cutoff * alpha\n",
      "Equal cutoff function type for all symmetry functions:\n",
      "CutoffFunction::CT_TANHU (2)\n",
      "f(r) = tanh^3(1 - r/rc)\n",
      "*******************************************************************************\n",
      "\n",
      "*** SETUP: SYMMETRY FUNCTIONS *************************************************\n",
      "\n",
      "Abbreviations:\n",
      "--------------\n",
      "ind .... Symmetry function index.\n",
      "ec ..... Central atom element.\n",
      "ty ..... Symmetry function type.\n",
      "e1 ..... Neighbor 1 element.\n",
      "e2 ..... Neighbor 2 element.\n",
      "eta .... Gaussian width eta.\n",
      "rs ..... Shift distance of Gaussian.\n",
      "la ..... Angle prefactor lambda.\n",
      "zeta ... Angle term exponent zeta.\n",
      "rc ..... Cutoff radius.\n",
      "ct ..... Cutoff type.\n",
      "ca ..... Cutoff alpha.\n",
      "ln ..... Line number in settings file.\n",
      "\n",
      "Short range atomic symmetry functions element  H :\n",
      "-------------------------------------------------------------------------------\n",
      " ind ec ty e1 e2       eta        rs la zeta        rc ct   ca    ln\n",
      "-------------------------------------------------------------------------------\n",
      "   1  H  2  H    1.000E-03 0.000E+00         1.200E+01  2 0.00   106\n",
      "   2  H  2  O    1.000E-03 0.000E+00         1.200E+01  2 0.00   116\n",
      "   3  H  2  H    1.000E-02 0.000E+00         1.200E+01  2 0.00   107\n",
      "   4  H  2  O    1.000E-02 0.000E+00         1.200E+01  2 0.00   117\n",
      "   5  H  2  H    3.000E-02 0.000E+00         1.200E+01  2 0.00   108\n",
      "   6  H  2  O    3.000E-02 0.000E+00         1.200E+01  2 0.00   118\n",
      "   7  H  2  H    6.000E-02 0.000E+00         1.200E+01  2 0.00   109\n",
      "   8  H  2  O    6.000E-02 0.000E+00         1.200E+01  2 0.00   119\n",
      "   9  H  2  O    1.500E-01 9.000E-01         1.200E+01  2 0.00   120\n",
      "  10  H  2  H    1.500E-01 1.900E+00         1.200E+01  2 0.00   110\n",
      "  11  H  2  O    3.000E-01 9.000E-01         1.200E+01  2 0.00   121\n",
      "  12  H  2  H    3.000E-01 1.900E+00         1.200E+01  2 0.00   111\n",
      "  13  H  2  O    6.000E-01 9.000E-01         1.200E+01  2 0.00   122\n",
      "  14  H  2  H    6.000E-01 1.900E+00         1.200E+01  2 0.00   112\n",
      "  15  H  2  O    1.500E+00 9.000E-01         1.200E+01  2 0.00   123\n",
      "  16  H  2  H    1.500E+00 1.900E+00         1.200E+01  2 0.00   113\n",
      "  17  H  3  O  O 1.000E-03 0.000E+00 -1  4.0 1.200E+01  2 0.00   170\n",
      "  18  H  3  O  O 1.000E-03 0.000E+00  1  4.0 1.200E+01  2 0.00   169\n",
      "  19  H  3  H  O 1.000E-02 0.000E+00 -1  4.0 1.200E+01  2 0.00   160\n",
      "  20  H  3  H  O 1.000E-02 0.000E+00  1  4.0 1.200E+01  2 0.00   158\n",
      "  21  H  3  H  O 3.000E-02 0.000E+00 -1  1.0 1.200E+01  2 0.00   155\n",
      "  22  H  3  O  O 3.000E-02 0.000E+00 -1  1.0 1.200E+01  2 0.00   168\n",
      "  23  H  3  H  O 3.000E-02 0.000E+00  1  1.0 1.200E+01  2 0.00   153\n",
      "  24  H  3  O  O 3.000E-02 0.000E+00  1  1.0 1.200E+01  2 0.00   167\n",
      "  25  H  3  H  O 7.000E-02 0.000E+00 -1  1.0 1.200E+01  2 0.00   150\n",
      "  26  H  3  H  O 7.000E-02 0.000E+00  1  1.0 1.200E+01  2 0.00   148\n",
      "  27  H  3  H  O 2.000E-01 0.000E+00  1  1.0 1.200E+01  2 0.00   145\n",
      "-------------------------------------------------------------------------------\n",
      "Short range atomic symmetry functions element  O :\n",
      "-------------------------------------------------------------------------------\n",
      " ind ec ty e1 e2       eta        rs la zeta        rc ct   ca    ln\n",
      "-------------------------------------------------------------------------------\n",
      "   1  O  2  H    1.000E-03 0.000E+00         1.200E+01  2 0.00   125\n",
      "   2  O  2  O    1.000E-03 0.000E+00         1.200E+01  2 0.00   135\n",
      "   3  O  2  H    1.000E-02 0.000E+00         1.200E+01  2 0.00   126\n",
      "   4  O  2  O    1.000E-02 0.000E+00         1.200E+01  2 0.00   136\n",
      "   5  O  2  H    3.000E-02 0.000E+00         1.200E+01  2 0.00   127\n",
      "   6  O  2  O    3.000E-02 0.000E+00         1.200E+01  2 0.00   137\n",
      "   7  O  2  H    6.000E-02 0.000E+00         1.200E+01  2 0.00   128\n",
      "   8  O  2  O    6.000E-02 0.000E+00         1.200E+01  2 0.00   138\n",
      "   9  O  2  H    1.500E-01 9.000E-01         1.200E+01  2 0.00   129\n",
      "  10  O  2  O    1.500E-01 4.000E+00         1.200E+01  2 0.00   139\n",
      "  11  O  2  H    3.000E-01 9.000E-01         1.200E+01  2 0.00   130\n",
      "  12  O  2  O    3.000E-01 4.000E+00         1.200E+01  2 0.00   140\n",
      "  13  O  2  H    6.000E-01 9.000E-01         1.200E+01  2 0.00   131\n",
      "  14  O  2  O    6.000E-01 4.000E+00         1.200E+01  2 0.00   141\n",
      "  15  O  2  H    1.500E+00 9.000E-01         1.200E+01  2 0.00   132\n",
      "  16  O  2  O    1.500E+00 4.000E+00         1.200E+01  2 0.00   142\n",
      "  17  O  3  H  O 1.000E-03 0.000E+00 -1  4.0 1.200E+01  2 0.00   165\n",
      "  18  O  3  O  O 1.000E-03 0.000E+00 -1  4.0 1.200E+01  2 0.00   175\n",
      "  19  O  3  H  O 1.000E-03 0.000E+00  1  4.0 1.200E+01  2 0.00   164\n",
      "  20  O  3  O  O 1.000E-03 0.000E+00  1  4.0 1.200E+01  2 0.00   174\n",
      "  21  O  3  H  H 1.000E-02 0.000E+00 -1  4.0 1.200E+01  2 0.00   159\n",
      "  22  O  3  H  H 1.000E-02 0.000E+00  1  4.0 1.200E+01  2 0.00   157\n",
      "  23  O  3  H  H 3.000E-02 0.000E+00 -1  1.0 1.200E+01  2 0.00   154\n",
      "  24  O  3  H  O 3.000E-02 0.000E+00 -1  1.0 1.200E+01  2 0.00   163\n",
      "  25  O  3  O  O 3.000E-02 0.000E+00 -1  1.0 1.200E+01  2 0.00   173\n",
      "  26  O  3  H  H 3.000E-02 0.000E+00  1  1.0 1.200E+01  2 0.00   152\n",
      "  27  O  3  H  O 3.000E-02 0.000E+00  1  1.0 1.200E+01  2 0.00   162\n",
      "  28  O  3  O  O 3.000E-02 0.000E+00  1  1.0 1.200E+01  2 0.00   172\n",
      "  29  O  3  H  H 7.000E-02 0.000E+00 -1  1.0 1.200E+01  2 0.00   149\n",
      "  30  O  3  H  H 7.000E-02 0.000E+00  1  1.0 1.200E+01  2 0.00   147\n",
      "-------------------------------------------------------------------------------\n",
      "Minimum cutoff radius for element  H: 12.000000\n",
      "Minimum cutoff radius for element  O: 12.000000\n",
      "Maximum cutoff radius (global)      : 12.000000\n",
      "*******************************************************************************\n",
      "\n",
      "*** SETUP: SYMMETRY FUNCTION GROUPS *******************************************\n",
      "\n",
      "Abbreviations:\n",
      "--------------\n",
      "ind .... Symmetry function group index.\n",
      "ec ..... Central atom element.\n",
      "ty ..... Symmetry function type.\n",
      "e1 ..... Neighbor 1 element.\n",
      "e2 ..... Neighbor 2 element.\n",
      "eta .... Gaussian width eta.\n",
      "rs ..... Shift distance of Gaussian.\n",
      "la ..... Angle prefactor lambda.\n",
      "zeta ... Angle term exponent zeta.\n",
      "rc ..... Cutoff radius.\n",
      "ct ..... Cutoff type.\n",
      "ca ..... Cutoff alpha.\n",
      "ln ..... Line number in settings file.\n",
      "mi ..... Member index.\n",
      "sfi .... Symmetry function index.\n",
      "e ...... Recalculate exponential term.\n",
      "\n",
      "Short range atomic symmetry function groups element  H :\n",
      "-------------------------------------------------------------------------------\n",
      " ind ec ty e1 e2       eta        rs la zeta        rc ct   ca    ln   mi  sfi e\n",
      "-------------------------------------------------------------------------------\n",
      "   1  H  2  H            *         *         1.200E+01  2 0.00     *    *    *  \n",
      "   -  -  -  -    1.000E-03 0.000E+00                 -  -    -   105    1    1  \n",
      "   -  -  -  -    1.000E-02 0.000E+00                 -  -    -   106    2    3  \n",
      "   -  -  -  -    3.000E-02 0.000E+00                 -  -    -   107    3    5  \n",
      "   -  -  -  -    6.000E-02 0.000E+00                 -  -    -   108    4    7  \n",
      "   -  -  -  -    1.500E-01 1.900E+00                 -  -    -   109    5   10  \n",
      "   -  -  -  -    3.000E-01 1.900E+00                 -  -    -   110    6   12  \n",
      "   -  -  -  -    6.000E-01 1.900E+00                 -  -    -   111    7   14  \n",
      "   -  -  -  -    1.500E+00 1.900E+00                 -  -    -   112    8   16  \n",
      "   2  H  2  O            *         *         1.200E+01  2 0.00     *    *    *  \n",
      "   -  -  -  -    1.000E-03 0.000E+00                 -  -    -   115    1    2  \n",
      "   -  -  -  -    1.000E-02 0.000E+00                 -  -    -   116    2    4  \n",
      "   -  -  -  -    3.000E-02 0.000E+00                 -  -    -   117    3    6  \n",
      "   -  -  -  -    6.000E-02 0.000E+00                 -  -    -   118    4    8  \n",
      "   -  -  -  -    1.500E-01 9.000E-01                 -  -    -   119    5    9  \n",
      "   -  -  -  -    3.000E-01 9.000E-01                 -  -    -   120    6   11  \n",
      "   -  -  -  -    6.000E-01 9.000E-01                 -  -    -   121    7   13  \n",
      "   -  -  -  -    1.500E+00 9.000E-01                 -  -    -   122    8   15  \n",
      "   3  H  3  H  O         *         *  *    * 1.200E+01  2 0.00     *    *    * *\n",
      "   -  -  -  -  - 1.000E-02 0.000E+00 -1  4.0         -  -    -   159    1   19 1\n",
      "   -  -  -  -  - 1.000E-02 0.000E+00  1  4.0         -  -    -   157    2   20 0\n",
      "   -  -  -  -  - 3.000E-02 0.000E+00 -1  1.0         -  -    -   154    3   21 1\n",
      "   -  -  -  -  - 3.000E-02 0.000E+00  1  1.0         -  -    -   152    4   23 0\n",
      "   -  -  -  -  - 7.000E-02 0.000E+00 -1  1.0         -  -    -   149    5   25 1\n",
      "   -  -  -  -  - 7.000E-02 0.000E+00  1  1.0         -  -    -   147    6   26 0\n",
      "   -  -  -  -  - 2.000E-01 0.000E+00  1  1.0         -  -    -   144    7   27 1\n",
      "   4  H  3  O  O         *         *  *    * 1.200E+01  2 0.00     *    *    * *\n",
      "   -  -  -  -  - 1.000E-03 0.000E+00 -1  4.0         -  -    -   169    1   17 1\n",
      "   -  -  -  -  - 1.000E-03 0.000E+00  1  4.0         -  -    -   168    2   18 0\n",
      "   -  -  -  -  - 3.000E-02 0.000E+00 -1  1.0         -  -    -   167    3   22 1\n",
      "   -  -  -  -  - 3.000E-02 0.000E+00  1  1.0         -  -    -   166    4   24 0\n",
      "-------------------------------------------------------------------------------\n",
      "Short range atomic symmetry function groups element  O :\n",
      "-------------------------------------------------------------------------------\n",
      " ind ec ty e1 e2       eta        rs la zeta        rc ct   ca    ln   mi  sfi e\n",
      "-------------------------------------------------------------------------------\n",
      "   1  O  2  H            *         *         1.200E+01  2 0.00     *    *    *  \n",
      "   -  -  -  -    1.000E-03 0.000E+00                 -  -    -   124    1    1  \n",
      "   -  -  -  -    1.000E-02 0.000E+00                 -  -    -   125    2    3  \n",
      "   -  -  -  -    3.000E-02 0.000E+00                 -  -    -   126    3    5  \n",
      "   -  -  -  -    6.000E-02 0.000E+00                 -  -    -   127    4    7  \n",
      "   -  -  -  -    1.500E-01 9.000E-01                 -  -    -   128    5    9  \n",
      "   -  -  -  -    3.000E-01 9.000E-01                 -  -    -   129    6   11  \n",
      "   -  -  -  -    6.000E-01 9.000E-01                 -  -    -   130    7   13  \n",
      "   -  -  -  -    1.500E+00 9.000E-01                 -  -    -   131    8   15  \n",
      "   2  O  2  O            *         *         1.200E+01  2 0.00     *    *    *  \n",
      "   -  -  -  -    1.000E-03 0.000E+00                 -  -    -   134    1    2  \n",
      "   -  -  -  -    1.000E-02 0.000E+00                 -  -    -   135    2    4  \n",
      "   -  -  -  -    3.000E-02 0.000E+00                 -  -    -   136    3    6  \n",
      "   -  -  -  -    6.000E-02 0.000E+00                 -  -    -   137    4    8  \n",
      "   -  -  -  -    1.500E-01 4.000E+00                 -  -    -   138    5   10  \n",
      "   -  -  -  -    3.000E-01 4.000E+00                 -  -    -   139    6   12  \n",
      "   -  -  -  -    6.000E-01 4.000E+00                 -  -    -   140    7   14  \n",
      "   -  -  -  -    1.500E+00 4.000E+00                 -  -    -   141    8   16  \n",
      "   3  O  3  H  H         *         *  *    * 1.200E+01  2 0.00     *    *    * *\n",
      "   -  -  -  -  - 1.000E-02 0.000E+00 -1  4.0         -  -    -   158    1   21 1\n",
      "   -  -  -  -  - 1.000E-02 0.000E+00  1  4.0         -  -    -   156    2   22 0\n",
      "   -  -  -  -  - 3.000E-02 0.000E+00 -1  1.0         -  -    -   153    3   23 1\n",
      "   -  -  -  -  - 3.000E-02 0.000E+00  1  1.0         -  -    -   151    4   26 0\n",
      "   -  -  -  -  - 7.000E-02 0.000E+00 -1  1.0         -  -    -   148    5   29 1\n",
      "   -  -  -  -  - 7.000E-02 0.000E+00  1  1.0         -  -    -   146    6   30 0\n",
      "   4  O  3  H  O         *         *  *    * 1.200E+01  2 0.00     *    *    * *\n",
      "   -  -  -  -  - 1.000E-03 0.000E+00 -1  4.0         -  -    -   164    1   17 1\n",
      "   -  -  -  -  - 1.000E-03 0.000E+00  1  4.0         -  -    -   163    2   19 0\n",
      "   -  -  -  -  - 3.000E-02 0.000E+00 -1  1.0         -  -    -   162    3   24 1\n",
      "   -  -  -  -  - 3.000E-02 0.000E+00  1  1.0         -  -    -   161    4   27 0\n",
      "   5  O  3  O  O         *         *  *    * 1.200E+01  2 0.00     *    *    * *\n",
      "   -  -  -  -  - 1.000E-03 0.000E+00 -1  4.0         -  -    -   174    1   18 1\n",
      "   -  -  -  -  - 1.000E-03 0.000E+00  1  4.0         -  -    -   173    2   20 0\n",
      "   -  -  -  -  - 3.000E-02 0.000E+00 -1  1.0         -  -    -   172    3   25 1\n",
      "   -  -  -  -  - 3.000E-02 0.000E+00  1  1.0         -  -    -   171    4   28 0\n",
      "-------------------------------------------------------------------------------\n",
      "*******************************************************************************\n",
      "\n",
      "*** SETUP: SYMMETRY FUNCTION SCALING ******************************************\n",
      "\n",
      "No scaling for symmetry functions.\n",
      "*******************************************************************************\n"
     ]
    }
   ],
   "source": [
    "# Run initialization steps (symmetry functions only).\n",
    "nnp.initialize()                                                                  \n",
    "nnp.loadSettingsFile(\"input.nn\")                                                  \n",
    "nnp.setupElementMap()                                                             \n",
    "nnp.setupElements()                                                               \n",
    "nnp.setupCutoff()                                                                 \n",
    "nnp.setupSymmetryFunctions()                                                      \n",
    "nnp.setupSymmetryMemory() # comment out when compiled with N2P2_FULL_SFD_MEMORY   \n",
    "nnp.setupSymmetryCache() # comment out when compiled with N2P2_NO_SF_CACHE        \n",
    "nnp.setupSymmetryFunctionGroups()\n",
    "# Either use symmetry function scaling...\n",
    "#nnp.setupSymmetryFunctionScaling(\"scaling.data\")                                  \n",
    "#nnp.setupSymmetryFunctionStatistics(False, False, True, False)\n",
    "# ... or calculate raw values.\n",
    "nnp.setupSymmetryFunctionScalingNone()\n",
    "\n",
    "# Print log file (for Option 2.) described above).\n",
    "#for line in m.log.getLog():\n",
    "#    so.write(line)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Create an empty structure.\n",
    "struct = pynnp.Structure()\n",
    "\n",
    "# Tell the structure which elements are to be expected,\n",
    "# i.e. pass the ElementMap from the NNP setup instance.\n",
    "# Note: this step is required!\n",
    "struct.setElementMap(nnp.elementMap)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of atoms:  24\n",
      "Number of atoms per element: \n",
      "H :  16\n",
      "O :  8\n"
     ]
    }
   ],
   "source": [
    "# Read in configuration from file.\n",
    "# WARNING: Do not read repeatedly as this will pile up atoms!\n",
    "struct.readFromFile(\"input.data.1\")\n",
    "\n",
    "# Print some information:\n",
    "print(\"Number of atoms: \", struct.numAtoms)\n",
    "print(\"Number of atoms per element: \")\n",
    "for (i, n) in enumerate(struct.numAtomsPerElement):\n",
    "    print(nnp.elementMap[i], \": \", n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cutoff radius =  12.0\n",
      "Atom    0 (O ): 142 neighbors\n",
      "Atom    1 (O ): 142 neighbors\n",
      "Atom    2 (O ): 142 neighbors\n",
      "Atom    3 (O ): 142 neighbors\n",
      "Atom    4 (O ): 142 neighbors\n",
      "Atom    5 (O ): 142 neighbors\n",
      "Atom    6 (O ): 142 neighbors\n",
      "Atom    7 (O ): 142 neighbors\n",
      "Atom    8 (H ): 127 neighbors\n",
      "Atom    9 (H ): 127 neighbors\n",
      "Atom   10 (H ): 127 neighbors\n",
      "Atom   11 (H ): 127 neighbors\n",
      "Atom   12 (H ): 127 neighbors\n",
      "Atom   13 (H ): 127 neighbors\n",
      "Atom   14 (H ): 127 neighbors\n",
      "Atom   15 (H ): 128 neighbors\n",
      "Atom   16 (H ): 127 neighbors\n",
      "Atom   17 (H ): 127 neighbors\n",
      "Atom   18 (H ): 128 neighbors\n",
      "Atom   19 (H ): 127 neighbors\n",
      "Atom   20 (H ): 127 neighbors\n",
      "Atom   21 (H ): 127 neighbors\n",
      "Atom   22 (H ): 127 neighbors\n",
      "Atom   23 (H ): 127 neighbors\n"
     ]
    }
   ],
   "source": [
    "# Retrieve cutoff radius form NNP setup.                                        \n",
    "cutoffRadius = nnp.getMaxCutoffRadius()                                           \n",
    "print(\"Cutoff radius = \", cutoffRadius)                                         \n",
    "                                                                                \n",
    "# Calculate neighbor list.                                                      \n",
    "struct.calculateNeighborList(cutoffRadius)\n",
    "\n",
    "# Show some information about neighbor list.\n",
    "for atom in struct.atoms:\n",
    "    print(\"Atom {0:4d} ({1:2s}): {2:3d} neighbors\".format(atom.index, nnp.elementMap[atom.element], atom.numNeighbors))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[3.0979046907343974, 1.18994287347951, 2.3374571003048064, 0.8149627350606994, 1.4183860085998368, 0.365071888883069, 0.8566908159542491, 0.11517221925856677, 0.6816891712438031, 0.5470457335903648, 0.5140233759056304, 0.2789086480393483, 0.3795853440912408, 0.08424583073547427, 0.16736514762008486, 0.0037220328749432313, 0.017450677340565067, 0.0005024982243135199, 0.2321654300938664, 0.015056415734351522, 0.02580794766232825, 0.08085925995465679, 0.04351493344073904, 0.00607693892348457, 0.0003358516494455779, 0.048211127016197244, 0.029932837634662226, 0.000989359235199765, 0.01398246084208952, 0.010175918586600824]\n"
     ]
    }
   ],
   "source": [
    "# Calculate symmetry functions for all atoms (using groups is generally faster).\n",
    "#nnp.calculateSymmetryFunctions(s, False)\n",
    "nnp.calculateSymmetryFunctionGroups(struct, False)\n",
    "                                                                                \n",
    "# Retrieve symmetry functions of atom with index 0.\n",
    "# Symmetry functions sort order is provided in the library output\n",
    "# of the setupSymmetryFunctions() method (see above).\n",
    "print(struct.atoms[0].G)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 15.6 ms, sys: 0 ns, total: 15.6 ms\n",
      "Wall time: 15.6 ms\n",
      "[2.86649377277164, 1.6229466695415529, 2.0623976954260583, 1.2201970615555326, 1.0990912879196195, 0.7414354094663689, 0.5115930320848044, 0.45659991006210426, 0.3768515741861182, 0.5650265555940194, 0.278675620398098, 0.2635626900178468, 0.19573039002565443, 0.12387824509705335, 0.0866044486663157, 0.03509025803430324, 0.02230215047551002, 0.031993442362933104, 0.019395663617398876, 0.1728751811637228, 0.01879781449053553, 0.007054820572245642, 0.08605197074485345, 0.004730188232226057, 0.003192176127904365, 0.022823231470083947, 0.0017684369314133184]\n"
     ]
    }
   ],
   "source": [
    "# Repeat the procedure for another structure.\n",
    "\n",
    "# First reset the structure, this will erase all data except for the ElementMap.\n",
    "struct.reset()\n",
    "\n",
    "struct.readFromFile(\"input.data.2\")\n",
    "struct.calculateNeighborList(cutoffRadius)\n",
    "%time nnp.calculateSymmetryFunctionGroups(struct, False)\n",
    "print(struct.atoms[0].G)"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
